//
//  Contact_DetailWorkRelationCell2.m
//  HuaRun2
//
//  Created by admin on 2017/9/9.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "Contact_DetailWorkRelationCell2.h"
#import "KeyValueLabel.h"
#import "Contact_DetailModel.h"
#import "LineView.h"

@interface Contact_DetailWorkRelationCell2 ()
//助理
@property (nonatomic, strong) KeyValueLabel * zhuLikeyValueLabel;

//汇报人
@property (nonatomic, strong) KeyValueLabel * topkeyValueLabel;
//主管
@property (nonatomic, strong) KeyValueLabel * mainkeyValueLabel;
//下属
@property (nonatomic, strong) KeyValueLabel * bottomkeyValueLabel;

@property (nonatomic, strong) UIImageView * phone1ImageView;
@property (nonatomic, strong) UIImageView * phone2ImageView;
@property (nonatomic, strong) UIImageView * emailImageView;


//分割线
@property (nonatomic, strong) LineView * lineView;

@end

@implementation Contact_DetailWorkRelationCell2

#pragma mark - life cycle
- (void)setDetailModel:(Contact_DetailModel *)detailModel {
    _detailModel = detailModel;
    _zhuLikeyValueLabel.valueLab.text = [NSString showSpaceStringWithStr: detailModel.assistantNameC];
    
    _phone1ValueLab.text = [NSString showSpaceStringWithStr: detailModel.assistantTel];
    _phone2ValueLab.text = [NSString showSpaceStringWithStr:detailModel.assistantMobile];
    _email1ValueLab.text = [NSString showSpaceStringWithStr:detailModel.assistantEmail];

    _topkeyValueLabel.valueLab.text  =[NSString showSpaceStringWithStr: detailModel.reportToName];
    _mainkeyValueLabel.valueLab.text  =[NSString showSpaceStringWithStr: detailModel.prNameOfSupervisor];
    _bottomkeyValueLabel.valueLab.text  =[NSString showSpaceStringWithStr: detailModel.prNameOfSubordinate];

}
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    
    [super viewInit];
    [self.contentView addSubview:self.zhuLikeyValueLabel];
    [self.contentView addSubview:self.topkeyValueLabel];
    [self.contentView addSubview:self.mainkeyValueLabel];
    [self.contentView addSubview:self.bottomkeyValueLabel];
    
    [self.contentView addSubview:self.phone1ImageView];
    [self.contentView addSubview:self.phone2ImageView];
    [self.contentView addSubview:self.emailImageView];

    [self.contentView addSubview:self.phone1ValueLab];
    [self.contentView addSubview:self.phone2ValueLab];    
    [self.contentView addSubview:self.email1ValueLab];
    
    [self.contentView addSubview:self.lineView];

}

- (void)layoutInit {
    
    //    [super layoutInit];
    
    weakself(ws);
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.top.mas_equalTo(ws.contentView).offset(0);
        make.bottom.mas_equalTo(ws.contentView).offset(-0);
    }];

    [self.zhuLikeyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.backView).offset(0);
        make.width.mas_equalTo(ws.backView);
        make.top.mas_equalTo(ws.backView).offset(kMargin10);
    }];
    
    [self.phone1ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.zhuLikeyValueLabel.mas_bottom).offset(kMargin10);
        make.right.mas_equalTo(ws.zhuLikeyValueLabel.keyLab);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    
    [self.phone2ImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.phone1ImageView);
        make.left.mas_equalTo(ws.phone1ValueLab.mas_right);
        make.size.mas_equalTo(ws.phone1ImageView);
    }];
    
    [self.emailImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.phone1ImageView.mas_bottom).offset(kMargin10);
        make.left.mas_equalTo(ws.phone1ImageView);
        make.size.mas_equalTo(ws.phone1ImageView);
    }];
    
    [self.phone1ValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.phone1ImageView);
        make.left.mas_equalTo(ws.phone1ImageView.mas_right).offset(kMargin10);
//        make.width.mas_equalTo(ws.zhuLikeyValueLabel).multipliedBy(0.5);
        make.width.mas_equalTo(100);
    }];
    
    [self.phone2ValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.phone2ImageView);
        make.left.mas_equalTo(ws.phone2ImageView.mas_right).offset(kMargin10);
        make.width.mas_equalTo(ws.phone1ValueLab);
    }];
    
    
    [self.email1ValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.phone1ValueLab.mas_bottom).offset(kMargin10);
        make.left.mas_equalTo(ws.emailImageView.mas_right).offset(kMargin10);
        make.right.mas_equalTo(ws.zhuLikeyValueLabel);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.emailImageView.mas_bottom).offset(kMargin10);
        make.left.mas_equalTo(ws.backView).offset(kMargin10 * 4);
        make.right.mas_equalTo(ws.backView).offset(- 2 * kMargin10);
        make.height.mas_equalTo(1);
    }];
    
    [self.topkeyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.mas_equalTo(ws.zhuLikeyValueLabel);
        make.top.mas_equalTo(ws.lineView.mas_bottom).offset(kMargin10);
    }];
    
    [self.mainkeyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.mas_equalTo(ws.zhuLikeyValueLabel);
        make.top.mas_equalTo(ws.topkeyValueLabel.mas_bottom).offset(kMargin10);
    }];
    
    [self.bottomkeyValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.mas_equalTo(ws.zhuLikeyValueLabel);
        make.top.mas_equalTo(ws.mainkeyValueLabel.mas_bottom).offset(kMargin10);
        make.bottom.mas_equalTo(ws.contentView).offset(-kMargin10);
    }];

}


//        "assistant"= "助理";
- (KeyValueLabel *)zhuLikeyValueLabel {
    if (!_zhuLikeyValueLabel) {
        self.zhuLikeyValueLabel = [[KeyValueLabel alloc] init];
        _zhuLikeyValueLabel.keyLab.text = NSLocalizedString(@"assistant", nil);
//        @"助理";
        
    }
    return _zhuLikeyValueLabel;
}

//        "reporter"= "汇报人";
- (KeyValueLabel *)topkeyValueLabel {
    if (!_topkeyValueLabel) {
        self.topkeyValueLabel = [[KeyValueLabel alloc] init];
        _topkeyValueLabel.keyLab.text = NSLocalizedString(@"reporter", nil);
//        @"汇报人";
        _topkeyValueLabel.valueLab.numberOfLines = 1;
    }
    return _topkeyValueLabel;
}

//        "charge"= "主管";
- (KeyValueLabel *)mainkeyValueLabel {
    if (!_mainkeyValueLabel) {
        self.mainkeyValueLabel = [[KeyValueLabel alloc] init];
        _mainkeyValueLabel.keyLab.text = NSLocalizedString(@"charge", nil);
//        @"主管";
        _mainkeyValueLabel.valueLab.numberOfLines = 1;
    }
    return _mainkeyValueLabel;
}

//        "xiashu"= "下属";
- (KeyValueLabel *)bottomkeyValueLabel {
    if (!_bottomkeyValueLabel) {
        self.bottomkeyValueLabel = [[KeyValueLabel alloc] init];
        //        _bottomkeyValueLabel.valueLab.text = kTestStr;
        _bottomkeyValueLabel.keyLab.text = NSLocalizedString(@"xiashu", nil);

//        @"下属";
        _bottomkeyValueLabel.valueLab.numberOfLines = 1;
    }
    return _bottomkeyValueLabel;
}

- (UIImageView *)phone1ImageView {
    if (!_phone1ImageView) {
        self.phone1ImageView = [UIImageView new];
        _phone1ImageView.image = [UIImage imageNamed:@"电话_lianxiren"];
    }
    return _phone1ImageView;
}

- (UIImageView *)phone2ImageView {
    if (!_phone2ImageView) {
        self.phone2ImageView = [UIImageView new];
        _phone2ImageView.image = [UIImage imageNamed:@"电话_lianxiren"];
    }
    return _phone2ImageView;
}

- (UIImageView *)emailImageView{
    if (!_emailImageView) {
        self.emailImageView = [UIImageView new];
        _emailImageView.image = [UIImage imageNamed:@"邮箱_laincxiren"];
    }
    return _emailImageView;
}

- (UILabel *)phone1ValueLab {
    if (!_phone1ValueLab) {
        self.phone1ValueLab = [UILabel new];
        _phone1ValueLab.textAlignment = NSTextAlignmentLeft;
        _phone1ValueLab.font = kGeneralFontSize;
        _phone1ValueLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _phone1ValueLab.text = [NSString stringWithFormat:@"phone1%@ %@ %@", kTestStr,
                                kTestStr, kTestStr];
        _phone1ValueLab.numberOfLines = 1;
    }
    return _phone1ValueLab;
}

- (UILabel *)phone2ValueLab {
    if (!_phone2ValueLab) {
        self.phone2ValueLab = [UILabel new];
        _phone2ValueLab.textAlignment = NSTextAlignmentLeft;
        _phone2ValueLab.font = kGeneralFontSize;
        _phone2ValueLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _phone2ValueLab.text = [NSString stringWithFormat:@"phone2%@ %@ %@", kTestStr,
                                kTestStr, kTestStr];
        _phone2ValueLab.numberOfLines = 1;
    }
    return _phone2ValueLab;
}

- (UILabel *)email1ValueLab {
    if (!_email1ValueLab) {
        self.email1ValueLab = [UILabel new];
        _email1ValueLab.textAlignment = NSTextAlignmentLeft;
        _email1ValueLab.font = kGeneralFontSize;
        _email1ValueLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _email1ValueLab.text = [NSString stringWithFormat:@"email1%@ %@ %@", kTestStr,
                                kTestStr, kTestStr];
        _email1ValueLab.numberOfLines = 1;
    }
    return _email1ValueLab;
}

- (LineView *)lineView {
    if (!_lineView) {
        self.lineView =  [LineView new];
        
    }
    return _lineView;
}
@end
